package com.linkstec.file;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BufferedReaderDemo {
   private static BufferedReader br;
   private static Logger logger = LoggerFactory.getLogger(BufferedReaderDemo.class);

public static void main(String[] args) throws Exception {
      
      String  thisLine = null;
      try{
         br = new BufferedReader((new FileReader("pom.xml")));
        /* while ((thisLine = br.readLine()) != null) {
            logger.info(thisLine);
         } */
         /*for (;;) {
        	 thisLine = br.readLine();
        	 logger.info(thisLine);
        	 logger.info("读取一行");
         }*/
         for (;;) {
        	 thisLine = read(br);
        	 logger.info(thisLine);
         }
      }catch(Exception e){
         e.printStackTrace();
      }
   }
public static String read(BufferedReader br) {
	String result = null;
	try {
		if ((result = br.readLine()) != null) {
			return result;
		} else {
			try {
				br.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	} catch (IOException e) {
		e.printStackTrace();
	}
	return result;
}
}